import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Bella on 24/04/2014.
 */

public class CategoryData {

    private String name;
    private int index;
    private List<ItemData> items;
    private Map<String, ItemData> map;

    /**
     * Constructor
     */
    public CategoryData(String name, List<ItemData> items) {
        this.name = name;
        this.items = items;
        index = 0;
        map = new HashMap<String, ItemData>();

        for (ItemData item : items) {
            map.put(item.getName(), item);
        }
    }

    public ItemData next() {
        if (index >= items.size())
            return null;

        return items.get(index++);
    }

    public ItemData find(String name) {
        return map.get(name);
    }
}
